package com.example.mp3ToWav;

import java.io.File;

public class Mp3ToWav {
    public static String mp3ToWav(String path) {
        int location = path.lastIndexOf(".");
        String path2 = path.substring(0,location);
        File source = new File(path);
        File target = new File(path2+".wav");
        AudioAttributes audio = new AudioAttributes();
        audio.setCodec(null);
        EncodingAttributes attrs = new EncodingAttributes();
        attrs.setFormat("wav");
        attrs.setAudioAttributes(audio);
        Encoder encoder = new Encoder();
        try {
            encoder.encode(source, target, attrs);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (InputFormatException e) {
            e.printStackTrace();
        } catch (EncoderException e) {
            e.printStackTrace();
        }
        return path2+".wav";

    }
}
